# WiFi AP测试程序的Makefile

# 编译器设置
CC = gcc
CFLAGS = -Wall -Wextra -pedantic -std=gnu99
LDFLAGS = 

# 目标文件
TARGET = wifi_test

# 源文件
SRCS = wifi_ap.c wifi_sta.c wifi_test.c

# 目标文件列表
OBJS = $(SRCS:.c=.o)

# 默认目标
all: $(TARGET)

# 编译规则
$(TARGET): $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $^

# 生成目标文件的规则
%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<

# 清理规则
clean:
	rm -f $(OBJS) $(TARGET)

# 安装规则
install:
	install -m 755 $(TARGET) /usr/local/bin

# 卸载规则
uninstall:
	rm -f /usr/local/bin/$(TARGET)

# 声明伪目标
.PHONY: all clean install uninstall

# 显示帮助信息
tips:
	@echo "使用说明:"
	@echo "  make           - 编译程序"
	@echo "  make clean     - 清理编译生成的文件"
	@echo "  make install   - 安装程序到/usr/local/bin"
	@echo "  make uninstall - 卸载程序"
	@echo "  make tips      - 显示此帮助信息"
	@echo "\n编译前注意:"
	@echo "  确保系统已安装必要的依赖:"
	@echo "  sudo apt-get install hostapd udhcpd"
	@echo "\n运行前注意:"
	@echo "  程序需要以root权限运行"
	@echo "  sudo ./wifi_test [options]"
	@echo "\n可用选项:"
	@echo "  -i <interface>   WiFi接口名称 (默认: wlan0)"
	@echo "  -s <ssid>        WiFi名称 (默认: WiFi_AP)"
	@echo "  -p <password>    WiFi密码 (至少8个字符)"
	@echo "  -c <channel>     WiFi信道 (1-13, 默认: 6)"
	@echo "  -m <mode>        WiFi模式 (g/n/ac, 默认: g)"
	@echo "  -h               显示帮助信息"